package com.alpha.feign.common.entity;

import com.alpha.core.entity.AlphaEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

/**
 * 用户实体
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@Data
@Schema(name = "用户")
@Accessors(chain = true)
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class User extends AlphaEntity {
    @NotNull(message = "用户名不能为空")
    @Schema(description = "用户名")
    private String username;

    @NotNull(message = "密码不能为空")
    @Schema(description = "密码")
    private String password;

    @NotNull(message = "姓名不能为空")
    @Schema(description = "姓名")
    private String name;

    @NotNull(message = "手机号码不能为空")
    @Schema(description = "手机号码")
    private String mobile;

    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "open_id")
    private String openId;

    @Schema(description = "union_id")
    private String unionId;

    @Schema(description = "租户Id")
    private Long tenantId;

    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    @Schema(description = "状态", defaultValue = "1")
    private Boolean enabled;

    @Schema(description = "描述")
    private String description;

    @SuppressWarnings("unused")
    public User(String username, String password, String name, String mobile) {
        // NotNull fields
        this.username = username;
        this.password = password;
        this.name = name;
        this.mobile = mobile;
    }
}
